package com.jerry.base.java8.lambda;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * 类名::new的方法引用
 *
 * @author Jerry
 * @since 2024/7/31 14:54
 */
public class MethodRef4 {

    static class Student {
        private String name;
        private Integer age;

        public Student() {
            name = "某人";
            age = 18;
        }

        public Student(String name) {
            this.name = name;
            age = 18;
        }

        public Student(String name, Integer age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "[" + name + ":" + age + "]";
        }
    }

    public static void main(String[] args) {
        Supplier<Student> s1 = Student::new;
        Function<String, Student> s2 = Student::new;
        BiFunction<String, Integer, Student> s3 = Student::new;

        System.out.println(s1.get());
        System.out.println(s2.apply("张三"));
        System.out.println(s3.apply("李四", 18));
    }
}
